# @Author   : tan90
# @Time     : 2025/1/25 12:56
from socket import socket, AF_INET, SOCK_DGRAM

server_udp_socket = socket(AF_INET, SOCK_DGRAM)
server_udp_socket.bind(("0.0.0.0", 9999))

print("UDP服务器启动成功")
while True:
    data, addr = server_udp_socket.recvfrom(1024)
    if data == b"OFF":
        break
    print("TCP客户端发送的数据为：", data.decode("utf-8"),addr)
    server_udp_socket.sendto("UDP服务器已收到数据".encode("utf-8"), addr)

server_udp_socket.close()
